odoo.define('add.tree.view.buttons', function (require) {
    "use strict";
    var core = require('web.core');
    var ListController = require('web.ListController');
    var ListView = require('web.ListView');
    var viewRegistry = require('web.view_registry');

    var qweb = core.qweb;

    var AddListViewController = ListController.extend({
        buttons_template: 'AddsListView.buttons',
        renderButtons: function () {
            this._super.apply(this, arguments); // Possibly sets this.$buttons
            if (this.$buttons) {
                var self = this;
                this.$buttons.on('click', '.o_button_add_tree_btn', function () {
                    alert('6666')
                    var actived_ids = [];
                    var select_value = $('tbody .o_list_record_selector input');
                    var state = self.model.get(self.handle, {raw: true});
                    //这里是获取列表中选中的record
                    for (var i=0;i<select_value.length;i++){
                       if (select_value[i].checked===true){
                            actived_ids.push(state.res_ids[i]);
                        }
                    }
                    self.do_action({
                        type: 'ir.actions.act_window',
                        res_model: 'basic.info',//向导模型
                        target: 'new',
                        views: [[false, 'form']],
                        context: {active_ids:actived_ids},
                    });
                });
            }
        }
    });
    //注册你的插件
    var AddsListView = ListView.extend({
        config: _.extend({}, ListView.prototype.config, {
            Controller: AddListViewController,
        }),
    });
    viewRegistry.add('add_buttons_tree', AddsListView);
})
